package com.yf.vip.service.impl;

import com.yf.vip.domain.DrUserVipLevel;
import com.yf.vip.dto.UserVipDTO;
import com.yf.vip.mapper.DrUserVipLevelMapper;
import com.yf.vip.service.UserVipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserVipServiceImpl implements UserVipService {

    @Autowired
    private DrUserVipLevelMapper drUserVipLevelMapper;

    @Override
    public UserVipDTO getUserVipByUid(Integer uid) {
        DrUserVipLevel form = new DrUserVipLevel();
        form.setUserid(uid);


        DrUserVipLevel userVipLevel = drUserVipLevelMapper.selectOne(form);

        UserVipDTO userVipDTO = new UserVipDTO();
        if (userVipLevel == null) {
            userVipDTO.setUid(99);
            userVipDTO.setVipLevel(3);
            userVipDTO.setVipName("VIP3");
        } else {
            userVipDTO.setUid(userVipLevel.getUserid());
            userVipDTO.setVipLevel(userVipLevel.getViplevel());
            userVipDTO.setVipName(userVipLevel.getVipname());
        }
        return userVipDTO;
    }
}
